<template>
	<view class="card-detail">
		<view class="top">
			<card-pack-item :data="data" showQrcode />
			<view style="margin-top: 30rpx;font-weight: 700;font-size: 30rpx;">
				选择被转入的卡
			</view>
			<view class="" style="width: 100%;height: 100rpx;margin-top: 20rpx;">
				<view class="" style="width: 10%;height: 100rpx;float: left;margin-top: 50rpx;">
					<image style="width: 70rpx;height: 70rpx;"
						src="https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/img/22e99971a7b5d0134a9177ff165967f855012c3b.png"
						mode=""></image>
				</view>
				<view class="" style="width: 85%;height: 100rpx;background-color: #fff;margin-top: 30rpx;float: right;" @click="card_selectlist">
					<view class=""
						style="width: 60%;height: 48rpx;float: left;font-size: 26rpx;line-height: 100rpx;margin-left: 20rpx;">
						游泳1000元充值卡
					</view>
					<view class="" style="width: 10%;height: 50rpx;float: right;margin-top: 36rpx;">
						<u-icon name="arrow-right" size="16" color="#999999"></u-icon>
					</view>
				</view>
			</view>
			<view style="margin-top: 50rpx;font-weight: 700;font-size: 30rpx;">
				转出额度
			</view>
			<view class="" style="width: 100%;height: 100rpx;background-color: #fff;margin-top: 30rpx;"
				v-if="data.type == 3">
				<view class=""
					style="width: 60%;height: 48rpx;float: left;font-size: 40rpx;line-height: 100rpx;margin-left: 20rpx;font-weight: 600;">
					<input type="text" placeholder="输入额度" style="margin-top: 30rpx;font-size: 26rpx;" v-model="exu">
				</view>
				<view class="" style="width: 10%;height: 50rpx;float: right;line-height: 100rpx;">
					元
				</view>
			</view>
			<view class="" style="width: 100%;height: 100rpx;background-color: #fff;margin-top: 30rpx;"
				v-if="data.type == 4 || data.type == 1">
				<view class=""
					style="width: 60%;height: 48rpx;float: left;font-size: 40rpx;line-height: 100rpx;margin-left: 20rpx;font-weight: 600;">
					<input type="text" placeholder="输入额度" style="margin-top: 30rpx;font-size: 26rpx;" v-model="exus">
				</view>
				<view class="" style="width: 10%;height: 50rpx;float: right;line-height: 100rpx;">
					次
				</view>
			</view>
			<view style="margin-top: 10rpx;font-size: 26rpx;color: #939393;">
				卡内余额{{data.else_text}}
			</view>
			<!-- <view style="width: 100%; height: auto;background: #fff; padding: 20rpx 30rpx; font-size: ;
			margin-top: 30rpx;
			background-color: white;
			border-radius: 7px;">
				<view style="width: 100%;height: 40rpx;font-size: 26rpx;
								font-weight: 500;
								color: #333333;">备注</view>
				<textarea placeholder=" " class="input-textare" height="200rpx" margin-top='20rpx'
					placeholder-style="font-size: 26rpx" v-model="order_remarks" />
			</view> -->
			<view class="" style="width: 92%;height: 100rpx;position: absolute;bottom: 10rpx;">
				<button style="background-color: #3E8AFE; color: #fff;border-radius: 50rpx 50rpx;" type="default" @click="transfer">确认转移</button>
			</view>
		</view>


	</view>
</template>

<script>
	import cardPackItem from '@/pages/personal/card-pack/card-pack-item.vue'
	const index = require('@/api/personal/index.js')
	export default {
		components: {
			cardPackItem
		},
		data() {
			return {
				data: {},
				cardno: '',
				id: 0,
				card_id:''
			}
		},
		onLoad(options) {
			this.cardno = options.cardno
			this.card_id = options.card_id
			this.getMyCardDetail()
		},
		methods: {
			card_selectlist(){
				uni.navigateTo({
					url:'./card_select?type=' + this.data.type
				})
			},
			gocard(index) {
				this.selectcard = index
			},

			// 获取我的卡包详情
			async getMyCardDetail() {
				let params = {
					cardno: this.cardno,
					project_id: getApp().globalData.projectId,
					user_id: uni.getStorageSync('phone'),
					open_id: uni.getStorageSync("openid"),
					appid: this.$https.weixinAppId,
					id:this.card_id
				}
				let res = await index.getMyCardDetail(params)
				if (res.code === 1) {
					this.data = res.data.cardData
				}
			},
			//转让
			async transfer() {
				let params = {
					project_id: getApp().globalData.projectId,
					appid: this.$https.weixinAppId,
					id: this.data.id, //卡id
					transfer_user: this.haoyouid, //好友id
					remark: this.remark, //备注
					price: '0',
					venue_id: this.data.venue_id,
					pay_method: '5',
					order_money: '0',
					phone: this.haoyouphone, //好友手机号
					to_times: this.exus, //次数
					to_money: this.exu, //钱
				}
				let res = await venues.shift(params)
				if (res.code === 1) {
					this.resultlist = res.data.info
					this.moniPay()
				}
			},
			// order_type 21挂失   22补卡  23  延期
			async moniPay() {
				var nowdate = new Date().valueOf();
				var that = this;
				let params = {
					app_id: that.$https.weixinAppId,
					project_id: getApp().globalData.projectId,
					id: that.data.id,
					venue_id: that.data.venue_id,
					price: '0', //价格
					pay_method: 1, //支付方式
					order_money: '0', //应付
					remark: that.remark, //备注
					add_time: nowdate,
					out_trade_no: that.resultlist.order_id,
					transaction_id: 'ZF001',
					goods_id: '1',
					order_type:'21'
				};
				// uni.request({
				// 	url: 'http://192.168.1.164/sass-test/public/index.php/api/court/moniPay',
				// 	method: 'POST',
				// 	data: {
				// 		app_id: that.$https.weixinAppId,
				// 		project_id: getApp().globalData.projectId,
				// 		id: that.data.id,
				// 		venue_id: that.data.venue_id,
				// 		price: '0', //价格
				// 		pay_method: 1, //支付方式
				// 		order_money: '0', //应付
				// 		remark: that.remark, //备注
				// 		add_time: nowdate,
				// 		out_trade_no: that.resultlist.order_id,
				// 		transaction_id: 'ZF001',
				// 		goods_id: '1',
				// 		order_type:'21'
				// 	},
				// 	header: {
				// 		'content-type': 'application/json', //自定义请求头信息
				// 	},
				// 	success: res => {
						
				// 	}
				// });
				let res = await venues.moniPay(params);
				if (res.code == 1) {
					uni.navigateTo({
						url: '/pages/personal/personal?backUp=1'
					})
			
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	@import url("@/static/css/personal/index.css");

	.card-detail {
		padding-bottom: env(safe-area-inset-bottom);
		background-color: #eeeeee;
		height: 100vh;

		.top {
			padding: 30rpx;
		}
	}
</style>